package sort;

public class InsertSort {
    public static void main(String[] args) {
        int []array=new int[]{2,4,1,3,5,7,12,5,11,21,10};
        //一般的插入排序
        for(int i=1;i<array.length;i++){
            int j=i-1;
            int temp=array[i];
            while(j>-1&&temp<array[j]){
                //移动
                array[j+1]=array[j];
                j--;
            }
            array[++j]=temp;
        }
        for (int i = 0; i <array.length ; i++) {
            System.out.print(array[i]+" ");
        }
    }

}
